package com.mccrea.pattern.state;

/**
 * @Classname AbstractState
 * @Description 抽象状态类
 * @Date 2021/5/24 0024 15:00
 * @Created by Mccrea_Gao
 */
public abstract class AbstractState {
    // 环境
    protected ScoreContext scoreContext;
    // 状态名
    protected String stateName;
    // 分数
    protected int score;

    public abstract void checkState();

    public void addScore(int x) {
        score += x;
        System.out.print("加上：" + x + "分，\t当前分数：" + score);
        checkState();
        System.out.println("分，\t当前状态：" + scoreContext.getState().stateName);
    }
}
